package br.com.fatecpg.operon;

import br.com.fatecpg.operon.frames.CadastroCursoslFrame;
import br.com.fatecpg.operon.frames.CadastroDisciplinasIFrame;
import br.com.fatecpg.operon.frames.CadastroProfessoresIFrame;
import br.com.fatecpg.operon.frames.ConsultaProfIlFrame;
import br.com.fatecpg.operon.frames.DisciplinasDosCursosIFrame;
import br.com.fatecpg.operon.frames.DisponibilidadeHorarioProfessoresIFrame;
import br.com.fatecpg.operon.frames.DisponibilidadeProfessoresDisciplinaIFrame;
import br.com.fatecpg.operon.frames.HorariosdeaulaJInternalFrame;
import br.com.fatecpg.operon.frames.ModulodeCursoIFrame;
import br.com.fatecpg.operon.frames.SaladeAulaIFrame;
import java.sql.SQLException;
import javax.swing.JOptionPane;


public class OperonMDI extends javax.swing.JFrame {

    /** Creates new form OperonMDI */
    public OperonMDI() {
        initComponents();
        setExtendedState(MAXIMIZED_BOTH);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        cadastroCursosMenuItem = new javax.swing.JMenuItem();
        cadastroDisciplinasMenuItem = new javax.swing.JMenuItem();
        cadastroProfessoresMenuItem = new javax.swing.JMenuItem();
        consultarProfessoresMenuItem = new javax.swing.JMenuItem();
        cursosMenuItem = new javax.swing.JMenuItem();
        horarioProfessoresMenuItem = new javax.swing.JMenuItem();
        disciplinaProfessoresMenuItem = new javax.swing.JMenuItem();
        horariosAulaMenuItem = new javax.swing.JMenuItem();
        moduloCursoMenuItem = new javax.swing.JMenuItem();
        salaAulaMenuItem = new javax.swing.JMenuItem();
        sairMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        sobreMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        fileMenu.setMnemonic('f');
        fileMenu.setText("Menu");

        cadastroCursosMenuItem.setText("Cadastro de Cursos");
        cadastroCursosMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadastroCursosMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(cadastroCursosMenuItem);

        cadastroDisciplinasMenuItem.setMnemonic('s');
        cadastroDisciplinasMenuItem.setText("Cadastro de Disciplinas");
        cadastroDisciplinasMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadastroDisciplinasMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(cadastroDisciplinasMenuItem);

        cadastroProfessoresMenuItem.setMnemonic('a');
        cadastroProfessoresMenuItem.setText("Cadastro de Professores");
        cadastroProfessoresMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadastroProfessoresMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(cadastroProfessoresMenuItem);

        consultarProfessoresMenuItem.setText("Consultar Professores");
        consultarProfessoresMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                consultarProfessoresMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(consultarProfessoresMenuItem);

        cursosMenuItem.setText("Cursos");
        cursosMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cursosMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(cursosMenuItem);

        horarioProfessoresMenuItem.setText("Horário Professores");
        horarioProfessoresMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                horarioProfessoresMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(horarioProfessoresMenuItem);

        disciplinaProfessoresMenuItem.setText("Disciplinas Professores");
        disciplinaProfessoresMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                disciplinaProfessoresMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(disciplinaProfessoresMenuItem);

        horariosAulaMenuItem.setText("Horarios de Aula");
        horariosAulaMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                horariosAulaMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(horariosAulaMenuItem);

        moduloCursoMenuItem.setText("Modulo Cursos");
        moduloCursoMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                moduloCursoMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(moduloCursoMenuItem);

        salaAulaMenuItem.setText("Salas de Aula");
        salaAulaMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salaAulaMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(salaAulaMenuItem);

        sairMenuItem.setMnemonic('x');
        sairMenuItem.setText("Sair");
        sairMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(sairMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setMnemonic('h');
        helpMenu.setText("Ajuda");

        sobreMenuItem.setMnemonic('a');
        sobreMenuItem.setText("Sobre");
        sobreMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sobreMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(sobreMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 624, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void sobreMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sobreMenuItemActionPerformed
       SobreJDialog dialog=new SobreJDialog(this, true);
       dialog.setVisible(true);
    }//GEN-LAST:event_sobreMenuItemActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
              try{
                   
            Conexao.Conectar("operon","operon");
        } catch (Exception ex){
            JOptionPane.showMessageDialog(this,
                    "Erro" + ex.getMessage(),
                    "Erro",
                    JOptionPane.ERROR_MESSAGE);
            System.exit(0);
            
        }
    }//GEN-LAST:event_formWindowOpened

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        try{
            Conexao.Desconectar();
        }catch(SQLException ex){
            JOptionPane.showMessageDialog(this, "Erro [Instrução SQL Inválida]"+ex.getMessage(),"Erro",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_formWindowClosed

    private void sairMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairMenuItemActionPerformed
        System.exit(0);
    }//GEN-LAST:event_sairMenuItemActionPerformed

    private void salaAulaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salaAulaMenuItemActionPerformed
        SaladeAulaIFrame sa = new SaladeAulaIFrame();
        sa.setClosable(true);
        sa.setResizable(true);
        sa.setIconifiable(true);
        sa.setVisible(true);
        desktopPane.add(sa);
    }//GEN-LAST:event_salaAulaMenuItemActionPerformed

    private void moduloCursoMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moduloCursoMenuItemActionPerformed
        ModulodeCursoIFrame mc = new ModulodeCursoIFrame();
        mc.setClosable(true);
        mc.setResizable(true);
        mc.setIconifiable(true);
        mc.setVisible(true);
        desktopPane.add(mc);
    }//GEN-LAST:event_moduloCursoMenuItemActionPerformed

    private void horariosAulaMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_horariosAulaMenuItemActionPerformed
        HorariosdeaulaJInternalFrame ha = new HorariosdeaulaJInternalFrame();
        ha.setClosable(true);
        ha.setResizable(true);
        ha.setIconifiable(true);
        ha.setVisible(true);
        desktopPane.add(ha);
    }//GEN-LAST:event_horariosAulaMenuItemActionPerformed

    private void disciplinaProfessoresMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disciplinaProfessoresMenuItemActionPerformed
        DisponibilidadeProfessoresDisciplinaIFrame dpd = new DisponibilidadeProfessoresDisciplinaIFrame();
        dpd.setClosable(true);
        dpd.setResizable(true);
        dpd.setIconifiable(true);
        dpd.setVisible(true);
        desktopPane.add(dpd);
    }//GEN-LAST:event_disciplinaProfessoresMenuItemActionPerformed

    private void horarioProfessoresMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_horarioProfessoresMenuItemActionPerformed
        DisponibilidadeHorarioProfessoresIFrame dhp = new DisponibilidadeHorarioProfessoresIFrame();
        dhp.setClosable(true);
        dhp.setResizable(true);
        dhp.setIconifiable(true);
        dhp.setVisible(true);
        desktopPane.add(dhp);
    }//GEN-LAST:event_horarioProfessoresMenuItemActionPerformed

    private void cursosMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cursosMenuItemActionPerformed
        DisciplinasDosCursosIFrame ddc = new DisciplinasDosCursosIFrame();
        ddc.setClosable(true);
        ddc.setResizable(true);
        ddc.setIconifiable(true);
        ddc.setVisible(true);
        desktopPane.add(ddc);
    }//GEN-LAST:event_cursosMenuItemActionPerformed

    private void consultarProfessoresMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consultarProfessoresMenuItemActionPerformed
        ConsultaProfIlFrame cnp = new ConsultaProfIlFrame();
        cnp.setClosable(true);
        cnp.setResizable(true);
        cnp.setIconifiable(true);
        cnp.setVisible(true);
        desktopPane.add(cnp);
    }//GEN-LAST:event_consultarProfessoresMenuItemActionPerformed

    private void cadastroProfessoresMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastroProfessoresMenuItemActionPerformed
        CadastroProfessoresIFrame cp = new CadastroProfessoresIFrame();
        cp.setClosable(true);
        cp.setResizable(true);
        cp.setIconifiable(true);
        cp.setVisible(true);
        desktopPane.add(cp);
    }//GEN-LAST:event_cadastroProfessoresMenuItemActionPerformed

    private void cadastroDisciplinasMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastroDisciplinasMenuItemActionPerformed
        CadastroDisciplinasIFrame cd = new CadastroDisciplinasIFrame();
        cd.setClosable(true);
        cd.setResizable(true);
        cd.setIconifiable(true);
        cd.setVisible(true);
        desktopPane.add(cd);
    }//GEN-LAST:event_cadastroDisciplinasMenuItemActionPerformed

    private void cadastroCursosMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastroCursosMenuItemActionPerformed
        CadastroCursoslFrame cc = new CadastroCursoslFrame();
        cc.setClosable(true);
        cc.setResizable(true);
        cc.setIconifiable(true);
        cc.setVisible(true);
        desktopPane.add(cc);
    }//GEN-LAST:event_cadastroCursosMenuItemActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(OperonMDI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(OperonMDI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(OperonMDI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(OperonMDI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new OperonMDI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem cadastroCursosMenuItem;
    private javax.swing.JMenuItem cadastroDisciplinasMenuItem;
    private javax.swing.JMenuItem cadastroProfessoresMenuItem;
    private javax.swing.JMenuItem consultarProfessoresMenuItem;
    private javax.swing.JMenuItem cursosMenuItem;
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JMenuItem disciplinaProfessoresMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JMenuItem horarioProfessoresMenuItem;
    private javax.swing.JMenuItem horariosAulaMenuItem;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem moduloCursoMenuItem;
    private javax.swing.JMenuItem sairMenuItem;
    private javax.swing.JMenuItem salaAulaMenuItem;
    private javax.swing.JMenuItem sobreMenuItem;
    // End of variables declaration//GEN-END:variables
}
